package com.erplan.studentmgt.desktop;

import java.sql.Connection;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;

import com.erplan.studentmgt.desktop.commons.GeneralFunctions;
import com.erplan.studentmgt.desktop.elements.AppClientArea;
import com.erplan.studentmgt.desktop.elements.AppMenu;
import com.erplan.studentmgt.desktop.elements.AppPopupMenu;
import com.erplan.studentmgt.desktop.elements.AppSplashScreen;
import com.erplan.studentmgt.desktop.elements.AppStatusBar;

public class StudentMgt {
	//=====================================================================
	//Global declarations
	//=====================================================================
	public static String toolText = "StuDB - Student Management";
	public static String toolTextSmall = "StuDB";
	public static String toolVersion = "v0.1";

    public static Connection db = null;

	//=====================================================================
	//Global objects
	//=====================================================================
	public static Display display = new Display();
	public static Shell shell = new Shell(display, SWT.MIN | SWT.CLOSE | SWT.RESIZE);
	public static Menu menuBar = null;
	public static Menu popupMenu = null;
    public static Composite clientArea = null;
    public static Composite statusBarArea = null;
	private static int shellHeight = 600, shellWidth = 800;

    //=====================================================================
    //Begin of main() function
	//=====================================================================
	public static void main(String[] args) {

		//=====================================================================
		//Generic Functions
	    //=====================================================================
		AppSplashScreen.showSplashScreen(display);							//Show Splash Screen
		GeneralFunctions.setShellInitSettings();							//Setting main window
		GeneralFunctions.setShellLayout();									//Setting layout of the Main Window
		AppMenu.init();														//Creating Main menu
		AppPopupMenu.init();												//Creating PopupMenu
		AppClientArea.init();												//Creating client area
		AppStatusBar.init();												//Creating Status Bar
		GeneralFunctions.setShellSizeAndLocation(shellWidth, shellHeight);	//Setting position of the Main Window
		shell.open();

		//================================================================
		//Cleanup code
		//================================================================
	    while (!shell.isDisposed()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose();
	}
}